// $Id: chosenton.h 64 2004-10-25 07:56:18Z hansemil $
#ifndef CHOSENTON_H
#define CHOSENTON_H

#include "singleton.h"
#include <iostream>
using namespace std;

/**
 * This is a neat template using base class for Chosenton classes. To use this
 * class, make sure to inherit from "Chosenton<YouClassName>" and don't forget
 * to protect you constructor (and to let it call the Chosenton constructor!)
 * and make this class your friend.
 */
template <typename Type>
class Chosenton : public Singleton<Type>
{
public:
	virtual ~Chosenton() {}

	static Type *getInstance()
	{
		if (!instance) {
			cout << "Warning: Call to Chosenton or one of it's subclasses without having created an instance!" << endl;
			instance = 0;
		}
		return instance;
	}

protected:
	/**
	 * @todo Document this!
	 */
	Chosenton(bool leaveInstance=false)
	{
		if(!leaveInstance){
			instance = (Type *)this;
		}
	}
	//template <typename Type>
	///friend class Singleton< Chosenton<Type> >;
	friend class Singleton<Type>;
};

#endif
